package xdTool

import initConfig.SysInitData
import sysUtil.SysCommUtil

import java.sql.Clob

class XdWidget {

    String name //控件名称
    Clob html //控件基本html代码以及样式
    String classFlag ;//用户判定widget类型
    String creator ;//操作人
    String updator ;//操作人
    Date dateCreated;
    Date lastUpdated;
    static constraints = {
        name(unique: true,nullable: false)
        creator(nullable: false)
        updator(nullable: true)
    }
    static mapping = {
        version false
    }


    static init(){

        if( XdWidget.countByClassFlag("xd-input") ==0 ){
            new XdWidget(
                    name: "文本框",
                    classFlag: "xd-input",
                    html: SysCommUtil.String2Clob("""
                <input type="text" name="" id="" class="xd-input layui-input" autocomplete="off" >
                """) ,
                    creator: SysInitData.SYS_ADMIN).save(flush: true)
        }

        if( XdWidget.countByClassFlag("xd-select") ==0 ){
            new XdWidget(
                    name: "下拉框",
                    classFlag: "xd-select",
                    html: SysCommUtil.String2Clob("""
                <select name="" id="" class="xd-select" xm-select-skin="default"  xm-select-height="36px" xm-select=""  xm-select-search="" xm-select-show-count="3" xm-select-radio="">
                <option value="0">否</option>
                <option value="1">是</option>
                </select>
                """) ,
                    creator: SysInitData.SYS_ADMIN).save(flush: true)
        }

        if( XdWidget.countByClassFlag("xd-date") ==0 ){
            new XdWidget(
                    name: "日期",
                    classFlag: "xd-date",
                    html: SysCommUtil.String2Clob("""
                <input type="text" id="" name="" class="xd-date layui-input" autocomplete="off">
                """) ,
                    creator: SysInitData.SYS_ADMIN).save(flush: true)

        }

        if( XdWidget.countByClassFlag("xd-panel-table") ==0 ){
            new XdWidget(
                    name: "数据表格",
                    classFlag: "xd-panel-table",
                    html: SysCommUtil.String2Clob("""
                <table class="layui-table" id="" lay-filter=""></table>
                """) ,
                    creator: SysInitData.SYS_ADMIN).save(flush: true)
        }

    }
}
